<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8"/>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Admin/css/bootstrap.min.css" />
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Admin/css/admin.css" />
    <script type='text/javascript' src='__PUBLIC__/Admin/js/jquery.min.js'></script>
    <script type='text/javascript' src='__PUBLIC__/Admin/js/layer/layer.js'></script>
    <script type='text/javascript' src='__PUBLIC__/Admin/js/ajaxfileupload.js'></script>
    <script type='text/javascript' src='__PUBLIC__/Admin/js/common.js'></script>
    <title>后台管理</title>
</head>
<body>
<div class="main-container clearfix">
    <div class="main-content">
        <div class="inner">
            <div class="mall-manage">
                <div class="comm-list" style="min-height:600px">
                    <div class="comm-top">
                        <h4 style="margin-bottom:0"><{:$info['id'] ? '修改' : '添加'}>后台用户</h4>
                        <div class="add_page_top"></div>
                    </div>
                    <form id="memberform" onsubmit="return false;">
                        <input type="hidden" name="id" value="<{$info.id}>"/>
                        <div class="shop_sort_box">
                            <div class="shop_sort">
                                <div class="shop_sort_title"><h4>用户名：</h4></div>
                                <div class="shop_sort_set">
                                    <input class="shop_sort_text" name="name" value="<{$info['admin']}>" type="text"/>
                                </div>
                            </div>
                            <div class="shop_sort">
                                <div class="shop_sort_title"><h4>密码：</h4></div>
                                <div class="shop_sort_set">
                                    <input class="shop_sort_text" name="password"  type="text"/>
                                </div>
                            </div>
                            <div class="shop_sort">
                                <div class="shop_sort_title"><h4>是否显示：</h4></div>
                                <div class="shop_sort_set">
                                    <select name="status" class="shop_sort_select" style="width: 36%">
                                        <option <{:$info['status'] == 1 ? 'selected' : ''}> value="1">开启</option>
                                        <option <{:$info['status'] == 2 ? 'selected' : ''}> value="2">禁用</option>
                                    </select>
                                </div>
                            </div>
                            <div class="shop_sort">
                                <div class="shop_sort_title"><h4>用户角色：</h4></div>
                                <div class="shop_sort_set">
                                    <select name="admin_type_id" class="shop_sort_select" style="width: 36%">
                                        <foreach name="type" item="vo">
                                            <option <{:$info['admin_type_id'] == $vo['id'] ? 'selected' : ''}> value="<{$vo['id']}>"><{$vo['name']}></option>
                                        </foreach>
                                    </select>
                                </div>
                            </div>

                            <div class="shop_sort">
                                <div class="shop_sort_title">
                                    <h4>&nbsp;</h4>
                                </div>
                                <div class="shop_sort_set">
                                    <span onclick="save(this);return false" id="saveBtn" class="btngreen30">完成</span>
                                    &nbsp;&nbsp;&nbsp;
                                    <span onclick="history.go(-1);" class="btngray30">返回</span>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    function uploadImage(id) {
        $.ajaxFileUpload({
            url: '<{:U("Tool/upload")}>',
            secureuri: false,
            fileElementId: id,
            dataType: 'json',
            success: function (data, status) {
                if (data.status == 1) {
                    $("#show img").attr('src', "__ROOT__" + data.info);
                    $("#show img").show();
                    $("#image").val(data.info);
                    $("#wangyao").val('已上传');
                } else {
                    layer.msg(data.info);
                }
            }
        });
    }

    function save(obj) {
        if ($("input[name='title']").val() == '') {
            note_info('主标题不能为空', obj, 'warn');
            return;
        }
        if ($("input[name='image']").val() == '') {
            note_info('图片不能为空', obj, 'warn');
            return;
        }
        if ($("input[name='position']").val() == '') {
            note_info('排序值不能为空', obj, 'warn');
            return;
        }
        $.post('<{:U("save")}>', $('#memberform').serialize(), function (res) {
            if (res.status == 1) {
                note_info(res.info, obj);
                setTimeout('location.href="<{:U('index')}>"', 1200);
            } else {
                note_info(res.info, obj, 'warn');
            }
        })
    }
</script>